import time
import cv2


import Processor.Converter as Converter


def toGrayImage(image):
    start = time.perf_counter()
    mat = Converter.QImage2Numpy(image)
    mat = cv2.cvtColor(mat, cv2.COLOR_RGBA2GRAY)
    mat = cv2.cvtColor(mat, cv2.COLOR_GRAY2BGRA)
    image = Converter.Numpy2QImage(mat)
    end = time.perf_counter()
    print('toGray', '耗时：', end - start)
    return image


def reversePhase(image):
    start = time.perf_counter()
    mat = Converter.QImage2Numpy(image)
    mat[:, :, 0:3] = 255 - mat[:, :, 0:3]
    image = Converter.Numpy2QImage(mat)
    end = time.perf_counter()
    print('reversePhase', '耗时：', end - start)
    return image

